package com.qianqian.service.config;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.qianqian.service.utils.HttpClientTools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class WxCpHttpClientConfig {
    private static final Logger log = LoggerFactory.getLogger(WxCpHttpClientConfig.class);
     public final String POST_URL="https://qyapi.weixin.qq.com/cgi-bin/";

    public JSONObject get(String path, Map<String, String> param) {
        return JSON.parseObject(HttpClientTools.get(POST_URL+path,null,param));
    }
    public JSONObject get(String path, Map<String, String> param,String accessToken) {
        param.put("access_token",accessToken);
        return JSON.parseObject(HttpClientTools.get(POST_URL+path,null,param));
    }

    public JSONObject post(String path,String jsonData,String accessToken) {
        return post(path,new HashMap<>(),jsonData,accessToken);
    }

    public JSONObject post(String path, Map<String, String> param,String data,String accessToken) {
        param.put("access_token",accessToken);
        return JSON.parseObject(HttpClientTools.post(POST_URL+path,null,param,data));
    }
}
